<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>选择用户</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treeview.jsp" %>
	<style type="text/css">
		.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}
	</style>
</head>
<body>
	<sys:message content="${message}"/>
	<div id="content" class="row-fluid">
		<div id="left" class="accordion-group" style="float:left;">
			<div class="accordion-heading">
		    	<a class="accordion-toggle">组织架构<i class="icon-refresh pull-right" onclick="refreshTree();"></i></a>
		    </div>
			<div id="ztree" class="ztree"></div>
		</div>
		<div id="openClose" class="close">&nbsp;</div>
		<div id="right" style="float:right;">
			<c:if test="${empty param.companyId}">
				<iframe id="officeContent" src="${ctx}/sys/user/dialogUserList?doDataFilter=${param.doDataFilter}" width="100%" height="91%" frameborder="0"></iframe>
			</c:if>
			<c:if test="${not empty param.companyId}">
				<iframe id="officeContent" src="${ctx}/sys/user/dialogUserList?officeId=${param.companyId}&doDataFilter=false" width="100%" height="91%" frameborder="0"></iframe>
			</c:if>
		</div>
		<div class="clear"></div>
		<div class="jszcselect selectlabel">
			
		</div>
	</div>
	<script type="text/javascript">
		var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
			callback:{onClick:function(event, treeId, treeNode){
					var id = treeNode.id == '0' ? '' :treeNode.id;
					var doDataFilter='${param.doDataFilter}';
					$('#officeContent').attr("src","${ctx}/sys/user/dialogUserList?officeId="+id+"&office.id="+id+"&office.name="+treeNode.name+"&doDataFilter="+doDataFilter);
				}
			}
		};
		
		function refreshTree(){
			
			var Num = "";
			for (var i = 0; i < 6; i++) {
				Num += Math.floor(Math.random() * 10);
			}
			
			var url="";
			var companyId='${param.companyId}';
			var isAll='${param.isAll}';
			
			if(companyId!="" && companyId!=null && companyId!=undefined){
				url="${ctx}/sys/office/treeData?doDataFilter=false&parent.id="+companyId+"&num="+Num;
			}else{
				url="${ctx}/sys/office/treeData?num="+Num+"&isAll="+isAll;
			}
			$.getJSON(url,function(data){
				$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
			});
		}
		
		refreshTree();
		var leftWidth = 180; // 左侧窗口大小
		var htmlObj = $("html"), mainObj = $("#main");
		var frameObj = $("#left, #openClose, #right, #right iframe");
		function wSize(){
			var strs = getWindowSize().toString().split(",");
			htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"});
			mainObj.css("width","auto");
			frameObj.height(410);
			var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
			$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
			$(".ztree").width(leftWidth - 10).height(350);
		}
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
</body>
</html>